<?php
class VerifyModel extends Model {
	function getMessagePageList($p,$where){
		$user = D('Verify');
		import('@.ORG.Page');
		$count = $user->where($where)->count();
		$Page = new Page($count,15);
		$show  = $Page->show();
		$messagelist = $user->where($where)->page($p.',15')->order('vid desc')->select();
		$users = array();
//		dump($messagelist);exit();

		foreach($messagelist as $key => $val){
			
			$guser[$key]=json_decode($val["content"],TRUE);
			
			if($messagelist[$key]["type"]=='add'){
				$messagelist[$key]["type"]="添加用户";
				$messagelist[$key]["content"]=$guser[$key]["name"];
			}elseif($messagelist[$key]["type"]=='edit'){
				$messagelist[$key]["type"]="编辑用户";
				$messagelist[$key]["content"]=$this->getUserone($guser[$key]['user_id']);
			}

			$messagelist[$key]["uid_send"]=$this->getUserone($messagelist[$key]["uid_send"]);
			$messagelist[$key]["uid_agree"]=$this->getUserone($messagelist[$key]["uid_agree"]);
		}
//		dump($messagelist);exit();
		return array('page'=>$show ,'messagelist'=>$messagelist);
	}
	
	//添加审核信息
	public function add($data){
		$m=M('verify');
		switch($data['type']){
			case 'add':
				$data['status']=0;
				if($m->create($data)){
					return $m -> add();
				}else{
					return FALSE;
				}
				break;
			case 'edit':
				if($m->create($data)){
					return $m -> add();
				}else{
					return FALSE;
				}
				break;
		}
	}
	
	public function getV($vid){
		$m=M('verify');
		$getv = $m->where(array('vid'=>$vid))->find();
//		dump($getv);exit();
		return $getv;
	}
	
	public function getMessageTips($where){
		$m=M('verify');
		$message_tip = $m->where($where)->count();
		return $message_tip;
	}
	
	function getUserone($uid){
		$m=M('User');
		$user=$m->where(array('user_id'=>$uid))->select();
		return $user[0]['nickname'];
	}
	
	
	
}
?>
